<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      //1.静态初始化
      var ay1 = ['aaa', 10, 10.5, 'bbb']
      //2.动态初始化 new
      var ay2 = new Array()
      //3. 动态初始化 指定元素
      var ay3 = new Array('aaa', 'bbb', 'ccc', 100)

      //输出:
      console.log('ay1:' + ay1)
      console.log('ay2:' + ay2)
      console.log('ay3:' + ay3)

      ay1[1] = 'cccc'
      console.log('ay1第二个元素:' + ay1[1])

      console.log('=================')
      for (var i = 0; i < ay1.length; i++) {
        console.log('第' + (i + 1) + '元素:' + ay1[i])
      }
      console.log('******************')
      for (var i in ay1) {
        console.log('第' + (parseInt(i) + 1) + '元素:' + ay1[i])
      }

      //4. 创建一个数组
      var ay4 = new Array()
      console.log(ay4.length)
      ay4[3] = 'aaa'
      console.log(ay4[3])
    </script>
  </head>
  <body></body>
</html>
